﻿using MediatR;
using S.Organization.Domian.Model;
using S.Organization.Infrastructure;
using S.Organization.Read.API.Application.Command.SupplierCommand;

namespace S.Organization.Read.API.Application.CommandHandler.SupplierCommandHandler
{
    public class GetSupplierByIdCommandHandler:IRequestHandler<GetSupplierByIdCommand, Supplier>
    {
        private readonly IBaseRepository<Supplier> _repository;


        public GetSupplierByIdCommandHandler(IBaseRepository<Supplier> repository)
        {
            _repository = repository;
        }

        public Task<Supplier> Handle(GetSupplierByIdCommand request, CancellationToken cancellationToken)
        {
            return _repository.GetAsync(request.SupplierId);
        }
    }
}
